{% extends "site.html" %}
{% block title %}{% endblock %}
{% block stylesheet %}{% load media %}{% media_prefix %}css/sklad.css{% endblock %}
{% block extrastyle %}<link rel="stylesheet" type="text/css" href="{% media_prefix %}css/sklad-tree.css">{% endblock %}
{% block globalconteiner %}

<script language="JavaScript">
function GetCookie(name) {
    var cookie = " " + document.cookie;
    var search = " " + name + "=";
    var setStr = null;
    var offset = 0;
    var end = 0;
    if (cookie.length > 0) {
        offset = cookie.indexOf(search);
        if (offset != -1) {
            offset += search.length;
            end = cookie.indexOf(";", offset)
            if (end == -1) {
                end = cookie.length;
            }
            setStr = unescape(cookie.substring(offset, end));
        }
    }
    return(setStr);
}

function SetCookie (name, value) {
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : '/';
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" +
        expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}

function UnHideNodeItem( node_id ){
    var node = document.getElementById( node_id );
    if(node){
        node.innerHTML = '&#9660;';
        node.parentNode.parentNode.parentNode.className = '';  
    }
    return true;
}

function UnHideOpenNodes(){
    var sOpenNode = GetCookie('opennode'); 
    if (sOpenNode != null){
        var aOpenNode = new Array();
        aOpenNode = sOpenNode.split(';');
        for(i=0;i<(aOpenNode.length-1);i++){
            UnHideNodeItem(aOpenNode[i]);
        }
    }
}

function UnHide( eThis ){
    if( eThis.innerHTML.charCodeAt(0) == 9658 ){
        eThis.innerHTML = '&#9660;'
        eThis.parentNode.parentNode.parentNode.className = '';
        OpenNode = GetCookie('opennode');
        if(OpenNode != null) SetCookie('opennode', OpenNode + eThis.id + ';')
        else SetCookie('opennode', eThis.id + ';');
        
    }else{
        eThis.innerHTML = '&#9658;'
        eThis.parentNode.parentNode.parentNode.className = 'cl';
        OpenNode = GetCookie('opennode');
        if(OpenNode != null){
            var b = OpenNode.indexOf(eThis.id)
            if (b != -1){
                var sa = OpenNode.slice(0,b);
                var sb = OpenNode.slice(b+eThis.id.length+1);
                SetCookie('opennode', sa + sb);
            }
        }
    }
    //alert(GetCookie('opennode'));
    return false;
}
</script> 

<h1>Склад</h1>
<div id="search">
    <form action="{% url search %}" method="GET">
        <input name="search_query" type="text" size="60" value="{{ query }}">
        <input class="default" type="submit" value="Найти"/> 
    </form>
</div>
<div id="main_menu">
    <A href="{% url index %}">Запчасти</A> 
    <A href="{% url document_all %}">Документы</A> 
</div>
{% block main %}

<table border="0" class="table_layout" style="margin-bottom:30px;">
    <tr>
        <td>
            <div id="contentleft">
            {% if perms.sklad.add_category %}
                {% if currentcategory %}
                    <p class="item_menu">
                        <a href="{% url category_create currentcategory %}">Новая подкатегория</a>
                    </p>
                {% else %}
                    <p class="item_menu">
                        <a href="{% url category_root_create %}">Новая категория</a>
                    </p>
                {% endif %}
            {% endif %}
            
            
            {% comment %}
            <div id="catlist">
            {% for item in cattree %}
              <div class="catitem">
                <samp style="padding-left: {{ item.csslevel }}px">
                {% if item.expanded %}	
                    {% if item.child_present %}
                        <a href="{% url category_view item.id %}?collaps=1">
                        <img src="{% media_prefix %}img/minus.gif" width="9" height="9"></a>
                    {% else %}
                        <img src="{% media_prefix %}img/rect.gif" width="9" height="9">
                    {% endif %}		
                {% else %}
                    {% if item.child_present %}
                        <a href="{% url category_view item.id %}?expand=1">
                        <img src="{% media_prefix %}img/plus.gif" width="9" height="9"></a>
                    {% else %}
                        <img src="{% media_prefix %}img/rect.gif" width="9" height="9">
                    {% endif %}		
                {% endif %}
                {% ifequal item.id currentcategory %}<b>{% endifequal %}
                   <a href="{% url category_view item.id %}">{{ item.name }}</a>
                {% ifequal item.id currentcategory %}</b>{% endifequal %}</samp>
              </div>
            {% endfor %}
            </div>
            {% endcomment %}
      
        
            <div class="treeview">   
                <ul>   
                    <li>
                        <div><p><a href="#" class="sc" onclick="return UnHide(this)">&#9660;</a>
                        <a href="#">Категории</a></p></div>
                        <ul>
                            {% load tree %}
                            {% tree category_tree|astree:"parent" %}
                                <a href="{% url category_view item.id %}" id="ti_{{item.id}}"><img src="{% media_prefix %}img/treefolder.png" class="i" />{{ item.name }}</a>
                            {% endtree %}
                        </ul>
                    </li>
                </ul>
            </div>
            
            <script language="JavaScript">                
                UnHideOpenNodes();
                
                {% for item in category_path %}
                UnHideNodeItem('tn_'+{{item.id}});
                {% endfor %} 
                
                var selectitem = document.getElementById('ti_{{ currentcategory }}');
                if(selectitem) 
                    selectitem.style.fontWeight = 'bold';  
                
           </script>               

      
            </div>
        </td>
        <td width="99%">
            <div id="contentright">
  
                {% if messages %}
                    <ul id="messages">
                    {% for message in messages %}
                        <li>{{ message|safe }}</li>
                    {% endfor %}
                    </ul>
                {% endif %}
                {% block path_menu %}
                <div id="view_menu">
                    <a href="{% url part_delivery %}">Выдача</a>                
                    <a href="{% url part_receipt %}">Поступление</a>
                </div>
                <div id="path-menu">
                    <A href="{% url index %}">Начало</A>
                    {% for cp in category_path %}
                        / <A href="{% url category_view cp.id %}">{{ cp.name }}</A>
                    {% endfor %} 
                </div>
                {% endblock %}
                {% block contenttitle %}
                {% endblock %} 
    
                {% block content %}
                    <h5>content</h5>
                {% endblock %}
            </div>
        </td>
    </tr>
</table>
{% endblock %}

{% endblock %}

{% block meta %}
{% if debug %}
<p>
    {{ sql_queries|length }} Quer{{ sql_queries|pluralize:"y,ies" }}
    {% ifnotequal sql_queries|length 0 %}
        (<span style="cursor: pointer;" onclick="var s=document.getElementById('debugQueryTable').style;s.display=s.display=='none'?'':'none';this.innerHTML=this.innerHTML=='Show'?'Hide':'Show';">Show</span>)
    {% endifnotequal %}
</p>
<table id="debugQueryTable" style="display: none;text-align:left;">
    <col width="1"></col>
    <col></col>
    <col width="1"></col>
    <thead>
        <tr>
            <th scope="col">#</th>
            <th scope="col">SQL</th>
            <th scope="col">Time</th>
        </tr>
    </thead>
    <tbody>
    {% for query in sql_queries %}
        <tr class="{% cycle odd,even %}">
            <td>{{ forloop.counter }}</td>
            <td>{{ query.sql|escape }}</td>
            <td>{{ query.time }}</td>
        </tr>
    {% endfor %}
    </tbody>
</table>
{% endif %}
Версия:&nbsp;{{ version_string }}&nbsp;&nbsp;&nbsp;&nbsp;Дата:&nbsp;10.08.2009

{% endblock %}	

